﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace WenSkin.Controls
{
    public class WenToolStrip : ToolStrip
    {
        public WenToolStrip() : base()
        {
            this.Renderer = new ToolStripRenderer();
            base.ImageScalingSize = new Size(32, 32);
            base.SetStyle(
                ControlStyles.UserPaint |
                ControlStyles.DoubleBuffer |
                ControlStyles.OptimizedDoubleBuffer |
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.ResizeRedraw |
                ControlStyles.SupportsTransparentBackColor, true);
            base.UpdateStyles();
            this.BackColor = Color.FromArgb(37, 37, 38);
        }

        private Color backColor;


        [DefaultValue(typeof(Size), "32,32")]
        public new Size ImageScalingSize { get => base.ImageScalingSize; set => base.ImageScalingSize = value; }

        [DefaultValue(typeof(Color), "37,37,38")]
        public new Color BackColor
        {
            get => backColor;
            set
            {
                backColor = value;
                base.BackColor = value;
                this.Invalidate();
            }
        }
        [DefaultValue(ToolStripRenderMode.Custom)]
        public new ToolStripRenderMode RenderMode { get => base.RenderMode; set { this.Renderer = new ToolStripRenderer(); } }

        protected override void OnPaintBackground(PaintEventArgs e)
        {
            Graphics g = e.Graphics.SetGDIHigh();
            g.SetClip(new Rectangle(0, 0, Width, Height));
            g.FillRectangle(new SolidBrush(this.BackColor), -1, -1, this.Width + 1, this.Height + 1);
        }
    }
}
